package io.example.service.impl;

import io.example.entity.Author;
import io.example.repository.AuthorRepository;
import io.example.service.AuthorAsyncService;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Description: AuthorAsyncServiceImpl.java .<br>
 * <p>Created Time: 2020/10/22 15:59 </p>
 *
 * @author <a href="mail to: mengxiangyuancc@gmail.com" rel="nofollow">孟祥元</a>
 */
@Service
public class AuthorAsyncServiceImpl implements AuthorAsyncService {
    @Autowired private AuthorRepository authorRepository;

    @Override
    public void add(Author author, Handler<AsyncResult<Author>> resultHandler) {
        resultHandler.handle(Future.succeededFuture(authorRepository.save(author)));
    }

    @Override
    public void getAll(Handler<AsyncResult<List<Author>>> resultHandler) {
        resultHandler.handle(Future.succeededFuture(authorRepository.findAll()));
    }
}
